﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Collections;
using GPCSC.Webs;
using ExtAspNet;

namespace GPCSC.Web.sjs
{
    public partial class UcountV : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
         
        }
        private void LoadData()
        {
            // 模拟从数据库返回数据表
            try
            {
                Hashtable htable = new Hashtable();
                htable.Add("@CL_POSTID_PK", Usual.f_querystringToString("id"));
                DataSet ds = new DataReturn().ReturnData(htable, "sel_ucount");
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            dr["sums"] = Usual.f_convertInt32(dr["ncsums"].ToString()) + Usual.f_convertInt32(dr["sqsums"].ToString()) + Usual.f_convertInt32(dr["qysums"].ToString());
                        }
                    }
                }
                Grid1.DataSource = ds;
                Grid1.DataBind();
            }
            catch (Exception ee)
            {
                throw (ee);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //string kyear = DropDownList1.SelectedValue;
            //string kmonth = DropDownList2.SelectedValue;
            //string jyear = DropDownList3.SelectedValue;
            //string jmonth = DropDownList4.SelectedValue;
            //if (kyear == "0" || kmonth == "0" || jyear == "0" || jmonth == "0")
            //{
            //    Alert.ShowInTop("请正确选择时间!");
            //    return;
            //}
            //else
            //{
            //    Hashtable htable = new Hashtable();
            //    htable.Add("@kyear",kyear);
            //    htable.Add("@kmonth",kmonth);
            //    htable.Add("@jyear", jyear);
            //    htable.Add("@jmonth", jmonth);

            //}
            DateTime kdate = Usual.f_convertDateTime(DatePicker1.SelectedDate);
            DateTime jdate = Usual.f_convertDateTime(DatePicker2.SelectedDate);
            Hashtable htable = new Hashtable();
            htable.Add("@kdate",kdate);
            htable.Add("@jdate",jdate);
            htable.Add("@CL_POSTID_PK", Usual.f_querystringToString("id"));
            DataSet ds = new SqlReadXml().ReaderDataSet("sel_ucount_bydate", htable);
            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        dr["sums"] = Usual.f_convertInt32(dr["ncsums"].ToString()) + Usual.f_convertInt32(dr["sqsums"].ToString()) + Usual.f_convertInt32(dr["qysums"].ToString());
                    }
                }

            }
            Grid1.DataSource = ds;
            Grid1.DataBind();

        }
    }
}